function AjaxXMLhttp(){
    function sendData(data){
        var str = "";
        if(data instanceof Object){
            for (let key in data) {
                if (data.hasOwnProperty(key)) {
                    str += key + "=" + data[key] + "&";
                }
            }
            return str.replace(/&$/g,"");
        }else{
                return data;
            }
    }
    function createXML(){
        try{
            return new window.XMLHttpRequest();
        }catch(e){
            try{
                return new ActiveXObject("MSXML2.XMLHTTP6.0");
            }catch(e){
                try{
                    return new ActiveXObject("MSXML2.XMLHTTP3.0");
                }catch(e){
                    try{
                        return new ActiveXObject("MSXML2.XMLHTTP");
                    }catch(e){
                        try{
                            return new ActiveXObject("Microsoft.XMLHTTP");
                        }catch(e){
                            throw new Error("浏览器版本过低！请更新");
                        }
                    }
                }
            }
        }
    }


    this.request = function(_config){
        var _ajax = createXML();
        _ajax.onreadystatechange = function(){
            if(_ajax.readyState === 4 && _ajax.status === 200){
                _config.success(_ajax.responseText);
            }
        }
    
        _ajax.open(_config.method ? _config.method : "post", _config.url , _config.async ? _config.async : "true");
        _ajax.setRequestHeader("Content-Type","applicecation/x-www-form-urlencoded;charset=UTF-8");
        _ajax.send(sendData(_config.data));
    }
}


var _ajax = new AjaxXMLhttp();